<script>
	import Vue from 'vue'
	import config from './config'
	import {
		getToken
	} from '@/utils/auth'
	import {
		AppType
	} from './utils/constant.js'

	export default {
		onLaunch: function() {
			// #ifdef H5
			// 判断浏览器环境
			var ua = navigator.userAgent.toLowerCase()
			if (ua.search(/MicroMessenger/i) > -1 && !uni.getStorageSync('appType')) {
			    // 微信环境
			    uni.setStorageSync('appType', AppType.MP)
			} else if (ua.search(/Alipay/i) > -1 && !uni.getStorageSync('appType')) {
			    // 支付宝环境
			    uni.setStorageSync('appType', AppType.ALI)
			} else {
			    if (!uni.getStorageSync('appType')) {
			        uni.setStorageSync('appType', AppType.H5)
			    }
			}
			// #endif
			// #ifdef MP-WEIXIN
			uni.setStorageSync('appType', AppType.MINI)
			const accountInfo = uni.getAccountInfoSync();
			console.info('accountInfo', accountInfo)
			uni.setStorageSync('appId', accountInfo.miniProgram.appId)
			// #endif
			uni.getSystemInfo({
				success: function(e) {
					console.info('getSystemInfo', e)
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};
					// #endif
					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif       
					// #ifdef MP-ALIPAY
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			})
		},
		methods: {
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import '@/static/scss/index.scss';

	/* 超出一行省略号 */
	.one-omit {
		white-space: nowrap;
		/*规定段落中的文本不进行换行*/
		overflow: hidden;
		/*内容会被修剪，并且其余内容是不可见的。*/
		text-overflow: ellipsis;
		/*显示省略号来代表被修剪的文本*/
	}
</style>